package dao;

import entity.Winner;

import java.sql.*;

/**
 * @author 23050
 * @version 1.0
 * @description: TODO
 * @date 2023/12/6 20:45
 */
public class ConnDao {

    public void save(Winner winner) throws SQLException {

        Conn conn = new Conn();
        Connection connection = conn.getConnection();
        String sql = "insert into winner (id,name,awardId) values (?,?,?)";
        PreparedStatement statement = connection.prepareStatement(sql);
        statement.setInt(1, winner.getId());
        statement.setString(2, winner.getName());
        statement.setInt(3, winner.getAwardId());
        int row = statement.executeUpdate();

        if (row>0){
            System.out.println("插入成功");
        }

    }


}
